package com.zcx.qshop.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.zcx.helper.bound.BoundView;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.util.UtilToast;
import com.zcx.qshop.QSApplication;
import com.zcx.qshop.R;
import com.zcx.qshop.conn.JsonSuggestionaddAsyGet;
import com.zcx.qshop.view.TitleView;

/**
 * Created by Administrator on 2015/8/22 0022.
 */
public class OpinionActivity extends QSActivity {

    @BoundView(R.id.title_view) private TitleView titleView;

    @BoundView(R.id.opinion_content) private EditText content;

    @BoundView(R.id.opinion_confirm) private View confirm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_opinion);

        titleView.showStyle(TitleView.Style.FULL);

        titleView.showType(TitleView.Type.BACK_TWO, TitleView.Type.NAME_ONE);

        titleView.setTitleName("意见反馈");

        titleView.setOnTitleItemClickListener(new TitleView.OnTitleItemClickListener() {

            @Override
            public void onBackClick() {

                finish();

            }

        });

        confirm.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                if(content.getText().toString().equals("")){

                    UtilToast.show(OpinionActivity.this, "内容不能为空");

                }else{

                    new JsonSuggestionaddAsyGet(QSApplication.QSPreferences.readUid(), content.getText().toString(), new AsyCallBack(){

                        @Override
                        public void onSuccess(String toast, int type, Object o) throws Exception {

                            finish();

                        }

                        @Override
                        public void onEnd(String toast, int type) throws Exception {

                            UtilToast.show(OpinionActivity.this, toast);

                        }

                    }).execute(OpinionActivity.this);

                }

            }

        });

    }

}
